-
Notifications
You must be signed in to change notification settings - Fork 67
Add @PulsarMessage
for default topic/schema
#565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduces the @PulsarTypeMapping annotation which can be used on message classes to specify default topic and/or schema info.
* Introduce a PulsarTypeMappingRegistry to cache annotations * Expand on the topic/schema resolver tests * Add support for KEY_VALUE on annotation
@PulsarTypeMapping
for default topic/schema
I'll look into it tomorrow, looks like a really nice addition! |
All glory goes to @alesharik |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the idea of annotating your message types with a little annotation that denotes the type and even the topic. I myself have done something similar on project I've worked on. Yet, I'm not convinced about the name @PulsarTypeMapping
. It clearly denotes that you are able to do some kind of type mapping yet the topic information feels shoehorned in and not the right place for an annotation called this way.
I would either propose to generify the name into something like @PulsarMessageDefinition
@PulsarMessageDetails
or just @PulsarMessage
or split the annotation into two and introduce a seperate @PulsarTopic
annotation specifically for topic resolution.
I'm missing a test that verifies that PulsarTemplate
can handle @PulsarTypeMapping
spring-pulsar/src/test/java/org/springframework/pulsar/core/DefaultTopicResolverTests.java
Show resolved
Hide resolved
spring-pulsar/src/main/java/org/springframework/pulsar/core/DefaultTopicResolver.java
Show resolved
Hide resolved
spring-pulsar-docs/src/main/antora/modules/ROOT/pages/reference/topic-resolution.adoc
Outdated
Show resolved
Hide resolved
Me too. It was @alesharik idea.
Me neither - you know what they say about naming and computer science ;)
Ha! The original PR was named
I thought about this approach but it would duplicate quite a bit of the work and for now a single annotation feels right. |
There is not one that explicitly tests this as the PulsarTemplate codes to the SchemaResolver interface and the assumption is that it is trusted and has been thoroughly tested itself. |
9dd0e17
to
3550cbc
Compare
@PulsarTypeMapping
for default topic/schema@PulsarMessage
for default topic/schema
This PR adds
@PulsarMessage
annotation to allow specifying default topic and/or schema info for a message class.cc: @jonasgeiregat do you mind giving this a review as well?